<template>
  <div>
    <common-head title="编辑联系人"></common-head>

    <div class="con">
      <van-address-edit 
      :area-list="addressInfo" show-postal show-set-default
      :address-info="contacts[parseInt($route.params.index)]"
        :area-columns-placeholder="['请选择', '请选择', '请选择']" @save="onSave" />
    </div>
  </div>
</template>

<script>
import CommonHead from '@components/CommonHead'
import { mapState, mapMutations } from 'vuex'

export default {
  components: {
    CommonHead
  },
  methods: {
    onSave(add){
      this.editContact({
        contact:add,
        index:parseInt(this.$route.params.index)
      })
      this.$router.go(-1)
    },
    ...mapMutations('address',['editContact'])
  },
  computed: {
    ...mapState({
      addressInfo: (state) => state.address.addressInfo,
      contacts: (state) => state.address.contacts

    })
  },
}
</script>

<style lang="scss" scoped>
</style>